package com.cn.lyl.servlet.lawyer;

import com.alibaba.fastjson.JSONObject;
import com.cn.lyl.model.LawyerModel;
import com.cn.lyl.service.LawyerService;
import com.cn.lyl.service.impl.LawyerServiceImpl;
import com.cn.lyl.util.Tool;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/back/lawyer/changeHomeState")
public class ChangeIsHomeServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        int id = Tool.stringToInt(req.getParameter("id"));
        LawyerModel lawyerModel = new LawyerModel();
        lawyerModel.setId(id);
        LawyerService lawyerService = new LawyerServiceImpl();
        String info = lawyerService.changeHomeState(lawyerModel);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result",info);
        resp.getWriter().print(jsonObject);
    }
}
